package com.zzyl.mapper;

import com.github.pagehelper.Page;
import com.zzyl.entity.CountTime;
import com.zzyl.entity.Reservation;
import com.zzyl.vo.ReservationVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface ReservationMapper {

    //根据微信用户ID查询取消预约记录
    List<Reservation> selectReservation(@Param("createBy") Long createBy);

    //查询每个时间段剩余预约次数
    List<CountTime> selectCountByTime(@Param("startTime") LocalDateTime startTime,
                                      @Param("endTime") LocalDateTime endTime);

    //新增预约参观
    void insert(Reservation reservation);

    //分页查询预约参观
    Page<ReservationVo> selectList(@Param("status") Integer status,
                                   @Param("createBy") Long createBy);

    //用户取消预约
    void updateById(Reservation reservation);

    //查询时间过期的预约信息
    List<Reservation> selectByStatus(@Param("status") Integer status,
                                     @Param("nowTime") LocalDateTime nowTime);

    //更新预约状态时间为已过期
    void updateByIds(@Param("ids") List<Long> ids);

    Reservation findById(Long id);

    void update(Reservation reservation);

    void deleteById(Long id);

    List<Reservation> findAll(@Param("userId") Long userId,
                              @Param("mobile") String mobile,
                              @Param("startTime") LocalDateTime startTime,
                              @Param("endTime") LocalDateTime endTime);

    Page<Reservation> findByPage(@Param("pageNum") int pageNum,
                                 @Param("pageSize") int pageSize,
                                 @Param("name") String name,
                                 @Param("phone") String phone,
                                 @Param("status") Integer status,
                                 @Param("type") Integer type,
                                 @Param("userId") Long userId,
                                 @Param("startTime") LocalDateTime startTime,
                                 @Param("endTime") LocalDateTime endTime);

}
